﻿@using KMF.WebUI.Areas.KMFadmin.Models
@using KMF.WebUI.Areas.KMFadmin.CustomHelpers
@using KMF.Common;
@model IEnumerable<KMF.Common.ContactListPaggingDto>

@{
    ViewBag.Title = "Tìm kiếm liên hệ";
    Layout = "~/Areas/KMFadmin/Views/Shared/_layout.cshtml";
}
<div class="toolBox">
    @Html.ToolBox(new List<object> { new Add { ClassCss = "Add", ActionName = "/KMFadmin/AdminContactList/AddContact" } })
</div>
<div class="box-search">
    @using (Html.BeginForm("SearchContact", "AdminContactList"))
    {
        @Html.TextBox("keyword")
        <input type="submit" value="Tìm kiếm" />
    }
</div>
<table class="table-odd table-plist">
    <tr>
        <th style="width: 30px;">STT</th>
        <th>Tên</th>
        <th>Email</th>
        <th>Điện thoại</th>
        <th style="width: 60px;">Trạng thái</th>
    </tr>

    @{
        if (Model.Any())
        {
            foreach (var item in Model)
            {
                <tr>
                    <td align="center">@item.STT</td>
                    
                    <td>
                        <a href="@Url.Action("Edit", "AdminContactList", new {id = @item.Id})">@item.ContactName</a>
                        <div class="info-ad-qv">
                            <a href="@Url.Action("Edit", "AdminContactList", new {id = @item.Id})">Sửa</a> |
                            <a href="">Sửa nhanh</a> |
                            <a href="javascript:void(0);" onclick="DeleteColor(@item.Id)" class="ad-qv-txt2">Xóa</a> |
                            <a href="">Xem</a>
                        </div>
                    </td>
                    <td>
                        <span>@item.Email</span> 
                    </td>
                    <td>
                        <span>@item.Phone</span> 
                    </td>
                    <td align="center">
                        <input type="checkbox" checked="@item.Active" />
                    </td>
                </tr>
            }
        }
    }
</table>
<div class="p-paging">
    @Html.PageLinks((PageInfo)ViewBag.PageInfo, i => Url.Action("Index", "AdminContactList", new { page = i }))
</div>
@section scripts
{
    <script type="text/javascript">
        function DeleteColor(id) {
            $.ajax({
                url: '/AdminContactList/DeleteContact',
                data: { id: id },
                success: function (data) {
                    if (data) {
                        alert('Xóa Contact thành công!');
                        window.location = 'Areas/KMFAdmin/AdminContactList';
                    } else {
                        alert('Xóa Contact thất bại!');
                    }
                },
                error: function () {
                    alert('Đã có lỗi xảy ra!');
                }
            });
        }
    </script>
}

